import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.util.Scanner;

public class aoj0033_file {

    static String txtRootPath;
    static String packagePath;

    static String className;
    static String txtName;
    static String txtSuffix;

    static {

        className = Thread.currentThread().getStackTrace()[1].getClassName();
        String[] tempArray = processPackageFile(className);

        txtRootPath = "aoj_files/";
        packagePath = tempArray[0];
        txtName = tempArray[1];
        txtSuffix = "_input.txt";
    }

    static String[] processPackageFile(String pathFile)
    {
        pathFile = pathFile.replace('.','/');
        int lastIndex = pathFile.lastIndexOf("/");

        String packagePath = pathFile.substring(0,lastIndex+1);
        String txtName = pathFile.substring(lastIndex+1);

        return new String[]{packagePath, txtName};
    }
    public static void main(String[] args) throws Exception{
        System.setIn(new BufferedInputStream(new FileInputStream( txtRootPath + packagePath + txtName + txtSuffix)));

        Scanner cin = new Scanner(new BufferedInputStream(System.in));

        int n ;
        while(cin.hasNext())
        {
            n = cin.nextInt();
            int a[] = new int[10];

            while(n>0)
            {
                for(int i=0; i<10; ++i)
                {
                    a[i] = cin.nextInt();
                }
                int l, r;
                l = r =0;
                boolean ans = true;
                for(int i=0; i<10; ++i)
                {
                    if(a[i] > l)
                    {
                        l = a[i];
                    }else if(a[i] > r)
                    {
                        r = a[i];
                    }else {
                        ans = false;
                        break;
                    }
                }
                System.out.format("%s\n", ans?"YES":"NO"); // 注意 格式 \n
                n--;
            }
        }

    }
}
